From 050f66992c7e41cd846b92bffa587816c98baca7 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Thu, 11 Oct 2007 19:23:40 +0100 Subject: [PATCH] x86: Fix time-scale calculation to avoid #DE fault. Signed-off-by: Keir Fraser --- xen/arch/x86/time.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c index b00ee01aa3..a9e2b5b735 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -214,6 +214,8 @@ static void set_time_scale(struct time_scale *ts, u64 ticks_per_sec) u32 tps32; int shift = 0; + ASSERT(tps64 != 0); + while ( tps64 > (MILLISECS(1000)*2) ) { tps64 >>= 1; @@ -221,7 +223,7 @@ static void set_time_scale(struct time_scale *ts, u64 ticks_per_sec) } tps32 = (u32)tps64; - while ( tps32 < (u32)MILLISECS(1000) ) + while ( tps32 <= (u32)MILLISECS(1000) ) { tps32 <<= 1; shift++; -- 2.30.2